package hyl.base.mq;

import hyl.core.MyFun;
import hyl.core.info.CMsg;
import hyl.core.run.IFinishT;

public abstract class BaseMQ implements ISendReceive<CMsg> {
	//一个实例只能订阅一个主题(大类) 但是可以有多个(小类)
	protected String _topic="_";
	protected String _key="*";
//	protected Map<String,Set<String>> _topics= new HashMap<String,Set<String>>();
	public int _mode = ISendReceive.I异步; // 异步
	public IFinishT<CMsg> _callback = null;
	//public IFinishT<CMsg> _sendcallback = null;
	@Override
	/**
	 *  大类==主题
	 *  
	 *  小类 ==key 或 = tag+key
	 *  
	 *  
	 */
	public ISendReceive<CMsg> set主题(String  大类, String 小类) {	
		//_topics.get(大类).add(小类);		
		_topic=MyFun.nvlStr(大类,"_");
		_key=MyFun.nvlStr(小类,"*");
		return this;
	}
	

	@Override
	/**
	 *  大类==主题
	 *  
	 *  
	 */
	public ISendReceive<CMsg> set主题(String 大类) {
		return set主题(大类, "*");
	}
	public ISendReceive<CMsg> set回调函数(IFinishT<CMsg> 回调函数,int 方式) {
		_callback=回调函数;
		_mode = MyFun.nvlInt(方式, ISendReceive.I异步);
		return this;
	}
	public ISendReceive<CMsg> set回调函数(IFinishT<CMsg> 回调函数) {
		_callback=回调函数;	
		return this;
	}
}

